package com.uenpay.im.ui.old.activity.oa;

import com.qiyunxin.android.http.net.HttpRequestType;
import com.uenpay.im.entities.RotateImageViewEntity;
import com.uenpay.im.invokeitems.HttpRequestHandle;

import java.util.ArrayList;

/**
 * @author SL
 * @created 2016-3-28 下午3:28:58
 * @copyRight http://www.qiyunxin.com
 * @function OA管理
 */
public class OaHandle {

	public interface IGetOaDataResultListener {
		void onDataResult(int status, String msg,
								   ArrayList<AppGroupEntity> arrayList);
	}

	/**
	 * 获取oa列表
	 * 
	 * @param entid
	 * @param mIGetOaDataResultListener
	 */
	public void getOaData(int entid,
			final IGetOaDataResultListener mIGetOaDataResultListener) {
		GetOaInvokeItem item = new GetOaInvokeItem(entid);
		HttpRequestHandle.onBaseRequest(item,
				HttpRequestType.SERVER_FAIL_AND_CACHE,
				new HttpRequestHandle.IRequestResultListener() {

					@Override
					public void onResult(Object resultObject, boolean isCache,
										 String failReason) {
						if (resultObject != null) {
							GetOaInvokeItem.GetOaInvokeItemResult result = ((GetOaInvokeItem) resultObject)
									.getOutput();
							if (result != null) {
								mIGetOaDataResultListener.onDataResult(
										result.status, result.msg,
										result.arrayList);
							} else {
								mIGetOaDataResultListener.onDataResult(-1,
										failReason, null);
							}
						} else {

							mIGetOaDataResultListener.onDataResult(-1,
									failReason, null);
						}
					}
				});

	}

	public interface IGetBlanResultListner {
		public void onGetBlanResult(int status, String msg,
									ArrayList<RotateImageViewEntity> arrayList);
	}

	/**
	 * 获取广告条
	 * 
	 * @param mIGetBlanResultListner
	 */
	public void getBlan(final IGetBlanResultListner mIGetBlanResultListner) {
		GetBlanInvokeItem item = new GetBlanInvokeItem();
		HttpRequestHandle.onBaseRequest(item,
				HttpRequestType.SERVER_FAIL_AND_CACHE,
				new HttpRequestHandle.IRequestResultListener() {

					@Override
					public void onResult(Object resultObject, boolean isCache,
							String failReason) {
						if (resultObject != null) {
							GetBlanInvokeItem.GetBlanInvokeItemResult result = ((GetBlanInvokeItem) resultObject)
									.getOutput();
							if (result != null) {
								mIGetBlanResultListner.onGetBlanResult(
										result.status, result.msg,
										result.arrayList);
							} else {
								mIGetBlanResultListner.onGetBlanResult(-1,
										failReason, null);
							}
						} else {
							mIGetBlanResultListner.onGetBlanResult(-1,
									failReason, null);
						}
					}
				});

	}

}
